<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>

    </style>
</head>
<body>
    <div>
        <h1>The Ajax Page</h1>
        <fieldset>
            <legend>Ajax 异步请求</legend>
            <button onclick="doAjaxGet01()">Ajax Request</button>
            <span id="id">Loading date...</span>
        </fieldset>
    </div>
</body>
<script>
    function doAjaxGet01(){
        var xhr = new XMLHttpRequest();
        xhr.onreadystatechange = function(){
            if(xhr.readyState==4&&xhr.status==200){
                var result=xhr.responseText;
                document.getElementById("id").innerHTML=result;
            }
        }
        xhr.open("get","http://localhost:8080/doAjaxGet",true);
        xhr.send(null);
    }
</script>
</html>